package VacationHomework.LeetCode;

import java.util.Stack;

public class MinStack {
    private Stack<Integer> element=new Stack<>();
    private Stack<Integer> support=new Stack<>();
    public MinStack() {
    }

    public void push(int val) {
        element.push(val);
        if(support.isEmpty()){
            support.push(val);
        }else {
            int tmp=support.peek();
            support.push(Math.min(tmp,val));
        }
    }

    public void pop() {
            element.pop();
            support.pop();
    }

    public int top() {
       return element.peek();
    }

    public int getMin() {
        return support.peek();

    }
}
